package www.com.zhongge.stack;

/**
 * @ClassName TestStack
 * @Description TODO 测试栈
 * @Author 笨忠
 * @Date 2025/7/26 15:52
 * @Version 1.0
 */
@SuppressWarnings("all")
public class TestStack {
    /**
     * 测试 队列实现栈
     * @param args
     */
    public static void main(String[] args) {
        MyStackOfQueue stack = new MyStackOfQueue();
        stack.push(1);
        stack.push(2);
        System.out.println(stack.top());
        System.out.println(stack.pop());
    }
    /**
     * 测试使用数组实现的栈
     * @param args
     */
    public static void main1(String[] args) {
        //创建栈对象
        MyStackOfArray<Integer> stack = new MyStackOfArray<>();
        //入栈
        stack.push(10);
        stack.push(23);
        stack.push(5);
        stack.push(7);
        //出栈
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println("====================");
        //取出栈顶元素
        System.out.println(stack.peek());

        MyStackOfArray<String> stack1 = new MyStackOfArray<>();
        stack1.push("俄文");
        System.out.println(stack1.pop());
    }
}
